<?php


namespace app\common\model;
use think\Model;

class Releases extends Model
{
    protected $autoWriteTimestamp = true; //自动写入时间戳

    public function add($data)
    {
        $data['status'] = 1;
        //$data['create_time'] = time();
        $this->save($data);
        return $this->id;
    }

    //通过1状态查询
    public function dataByStatus($data){
        $data []= [
            ['status','=','1']
        ];

        $order = ['id'=>'desc'];
        $result = $this->where($data)->order($order)->paginate(6);
        //echo $this->getLastSql();
        return $result;
    }

    //通过0.1状态查询
    public function dataByAllStatus(){
        $data = [
            'status'=>[0,1]
        ];

        $order = ['id'=>'desc'];
        $result = $this->where($data)->order($order)->paginate(5);
        //echo $this->getLastSql();exit;
        return $result;
    }


    //通过ID

    public function dataById($id){
        $data = [
            'id'=>$id,
            'status'=>1,
        ];

        $rel = $this->where($data)->select();

        return $rel;
    }


}
